#ifndef GROUP_H
#define GROUP_H

#include <list>
#include "Character.h"
#include "Vector2D.h"
#include "State Machine.h"
#include "Path.h"
#include "GroupTypeDefinitions.h"

struct FollowOffsetInfo
{
	Path* thePath;
	Vector2D theOffset;
};

class Group
{
private:
	int m_ID;
	static int m_iNextValidID;
	MemberList m_Members; // The members of this group.

	int mType;

	int m_FormationID;
	int m_CommanderID;
	int m_NumberUnits;

	vector<Vector2D> mUnitPositions;
	vector<Vector2D> mDesiredPositions;
	list<Vector2D> m_lOffsets;

	Vector2D m_MoveGoal;
	Vector2D m_Centroid;

	Character* m_pLeader;
	Path* m_pGroupPath;

	vector<Vector2D> m_Hull; // points making up the hull. 

public:
	Group();
	~Group();

	int GetID() {return m_ID;}

	StateMachine<Group>* m_pGroupState;

	void Add(Character* aChr);
	void Remove(Character* aChr);

	void UpdateUnitPositions();
	Vector2D MoveGoal() {return m_MoveGoal;}

	Character* Leader() {return m_pLeader;}
	void SetLeader();

	void Move(Vector2D destination);

	void CalculateOffsets();
	Vector2D NextFreeOffset();
	
	bool inGroup(Character* aChar);

	MemberList Members();

	void Update();
	void Render();
	
	void CalculateCentroid();
	Path* GroupPath() {return m_pGroupPath;}

};
#endif